﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using INSE6260.OnlineBanking.Infrastructure;
using INSE6260.OnlineBanking.Infrastructure.Domain;
using INSE6260.OnlineBanking.Model.Accounts;

namespace INSE6260.OnlineBanking.Model.Customers
{
    public class Client : EntityBase, IAggregateRoot
    {
        public int Id { get; set; }
        [Required(AllowEmptyStrings = false, ErrorMessage = "Customer Name can not be null.")]
        [StringLength(50)]
        public string FirstName { get; set; }
        [Required(AllowEmptyStrings = false, ErrorMessage = "Customer Family can not be null.")]
        [StringLength(50)]
        public string LastName { get; set; }
        [StringLength(50)]
        public string Email { get; set; }
        public string Address { get; set; }
        public string Telephone { get; set; }
        public int OccupationTypeId { get; set; }
        public int EmploymentTypeId { get; set; }
        public byte Gender { get; set; }

        public virtual List<Account> Accounts { get; set; }
        public virtual EmploymentType.EmploymentType EmploymentType { get; set; }
        public virtual OccupationType.OccupationType OccupationType { get; set; }
        public virtual List<Payee.Payee> Payees { get; set; }
        protected override void Validate()
        {
            if (FirstName == LastName) AddBrokenRule(new BusinessRule(@"FirstName", "Name and Family can not be equal."));
        }
    }
}
